#include "Vector3.h"

void Vector3::setVector(float myX, float myY,float myZ)
{
	x = myX;
	y = myY;
	z = myZ;
}

void Vector3::setVector(Vector3 myVector)
{
	x = myVector.x;
	y = myVector.y;
	z = myVector.z;
}

bool Vector3::equals(Vector3 myVector)
{
	if(x == myVector.x && y == myVector.y && z == myVector.z)
	{
		return true;
	}
	return false;
}

float Vector3::calcMagnitude()
{
	return sqrt(x*x + y*y + z*z);
}

Vector3 Vector3::calcNormalVect()
{
	float magnitude = calcMagnitude();
	return Vector3(x/magnitude, y/magnitude, z/magnitude);
}

Vector3 Vector3::scale(float scale)
{
	return Vector3(x*scale,y*scale,z*scale);
}

Vector3 Vector3::add(Vector3 myVector)
{
	return Vector3(x+myVector.x, y+myVector.y, z+myVector.z);
}

Vector3 Vector3::subtract(Vector3 myVector)
{
	return Vector3(x-myVector.x, y-myVector.y, z-myVector.z);
}

float Vector3::dot(Vector3 myVector)
{
	return x*myVector.x + y*myVector.y + z*myVector.z;
}

Vector3 Vector3::cross(Vector3 myVector)
{
	return Vector3(y*myVector.z - z*myVector.y,
					z*myVector.x - x*myVector.z,
					x*myVector.y - y*myVector.x);
}

Vector3 Vector3::projectOnto(Vector3 myVector)
{
	float myVectMag = myVector.calcMagnitude();
	float projectionLength = dot(myVector) / (myVectMag*myVectMag);
	return(myVector.scale(projectionLength));
}